package com.damie.component;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
@Slf4j
public class MyMetaObjectHandler implements MetaObjectHandler {
    //处理新增
    @Override
    public void insertFill(MetaObject metaObject) {
        log.info("开始insert填充......");
        this.setFieldValByName("userCreateTime",new Date(),metaObject);
        this.setFieldValByName("userUpdateTime",new Date(),metaObject);
        this.setFieldValByName("createTime",new Date(),metaObject);
        this.setFieldValByName("updateTime",new Date(),metaObject);
        this.setFieldValByName("ratingCreateTime",new Date(),metaObject);
        this.setFieldValByName("wasteOrderComolainCreateTime",new Date(),metaObject);
    }

    //处理修改
    @Override
    public void updateFill(MetaObject metaObject) {
        log.info("开始update填充......");
        this.setFieldValByName("userUpdateTime",new Date(),metaObject);
        this.setFieldValByName("updateTime",new Date(),metaObject);
        this.setFieldValByName("ratingUpdateTime",new Date(),metaObject);
    }
}